{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## CORDIC Testbench\n",
    "\n",
    "\n",
    "This notebook is to test the implementation of a CORDIC running on the programmable logic. The CORDIC is used to convert cartesian to polar coordinates. The output is compared with a Python calculation of the coordinate transform. It takes in x and y and gives out r and theta where r is the radius and theta is the angle."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pynq import Overlay\n",
    "from pynq import MMIO\n",
    "import numpy as np\n",
    "import struct\n",
    "import binascii\n",
    "import cmath\n",
    "import random\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "NUM_SAMPLES = 50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "ol=Overlay('./cordic.bit') #Change name of bitstream as required"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "cordic_ip=MMIO(0x43C00000,10000) #Change base address as required"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "r_error=np.zeros(NUM_SAMPLES)\n",
    "theta_error=np.zeros(NUM_SAMPLES)\n",
    "ind=np.arange(NUM_SAMPLES)\n",
    "r_rmse=np.zeros(NUM_SAMPLES)\n",
    "theta_rmse=np.zeros(NUM_SAMPLES)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(NUM_SAMPLES):\n",
    "    #Generating random inputs\n",
    "    x=random.uniform(-1,1)\n",
    "    y=random.uniform(-1,1)\n",
    "    \n",
    "    #Computing golden output\n",
    "    cn=complex(x,y)\n",
    "    cn=cmath.polar(cn)\n",
    "    \n",
    "    #Converting input to bytes to be sent to FPGA\n",
    "    x=(struct.unpack('<I', struct.pack('<f', x))[0])\n",
    "    y=(struct.unpack('<I', struct.pack('<f', y))[0])\n",
    "    \n",
    "    #Writing values to the FPGA\n",
    "    cordic_ip.write(0x10,x)                             #Change the offset as mentioned in vivado file\n",
    "    cordic_ip.write(0x18,y)                             #Change the offset as mentioned in vivado file\n",
    "    \n",
    "    #Starting and stopping the IP (Don't change this)\n",
    "    cordic_ip.write(0x00,1)\n",
    "    cordic_ip.write(0x00,0)\n",
    "    \n",
    "    #Reading from IP\n",
    "    r=hex(cordic_ip.read(0x20))                         #Change the offset as mentioned in vivado file\n",
    "    r=r[2:]\n",
    "    theta=hex(cordic_ip.read(0x28))                     #Change the offset as mentioned in vivado file\n",
    "    theta=theta[2:]\n",
    "    \n",
    "    #Converting to float\n",
    "    if r!=0:\n",
    "        r=struct.unpack('>f', binascii.unhexlify(r))\n",
    "        r=r[0]\n",
    "    if theta!=0:\n",
    "        theta=struct.unpack('>f', binascii.unhexlify(theta))\n",
    "        theta=theta[0]\n",
    "        \n",
    "    #Comparing with golden output    \n",
    "    r_error[i]=\"{0:.6f}\".format(abs(r-cn[0]))\n",
    "    theta_error[i]=\"{0:.6f}\".format(abs(theta-cn[1]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Verifying Functionality"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Radius RMSE:  7.2129189653e-05 Theta RMSE: 6.89960868456e-05\n",
      "PASS\n"
     ]
    }
   ],
   "source": [
    "sum_sq_r=0\n",
    "sum_sq_theta=0\n",
    "for i in range(NUM_SAMPLES):\n",
    "    sum_sq_r =sum_sq_r+(r_error[i]*r_error[i])\n",
    "    r_rmse = np.sqrt(sum_sq_r / (i+1))\n",
    "    sum_sq_theta =sum_sq_theta+(theta_error[i]*theta_error[i])\n",
    "    theta_rmse = np.sqrt(sum_sq_theta / (i+1))\n",
    "print(\"Radius RMSE: \", r_rmse, \"Theta RMSE:\", theta_rmse)    \n",
    "if r_rmse<0.001 and theta_rmse<0.001:\n",
    "    print(\"PASS\")\n",
    "else:\n",
    "    print(\"FAIL\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Displaying Errors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAsgAAAFgCAYAAACmDI9oAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3X+83Vdd5/vXm4QUldJe0vijTWuiDaOpv3BiwcG51hZoCki4Y5FUUWCKnTu3FVFG2qpTmUocOs6DDjws5VZagSqT1qr0DMSpYst4RfojWKw2EjymxaaADWla+TFtTfncP/YK/XZ3n5yT5Oxz9t7n9Xw8ziPfvb7r+9lrnXOy8sna6/tdqSokSZIk9TxtsRsgSZIkjRITZEmSJKnDBFmSJEnqMEGWJEmSOkyQJUmSpA4TZEmSJKnDBFlLWpJ7k7ywHf9SkvcsdpskaVIkeUuS31nsdkiHygRZY6UltP87yZeSfD7Je5M8cz5iV9WvV9Xr5yPWAUlOS/LV1t7u1w/O5/tI0mLoG9e+2hmfv5TkJ48w9hEl10lem+TxAePv8UfSLi0NJsgaRz9aVc8Evg94LnDxIrdnNp+tqmf2fX28v1J6njZb2WySLD/SBkvSXHTHNeAfaONz+/rdxW4f8PEB4+9n+ysNGjcPZyxNsuxwG6rRYoKssVVVnwduopcoA5DkpUnuTPJPSe5L8pbuNUl+KslnkuxN8st95742W9Fmfnf3ne8uxzg1yfb2Pv+Y5O2H04ckH02yJcnHgK8A3zZD2fFJppI8mGQ6yc/0tfuGJL+T5J+A1x5OWyRpSFYkeX+SLya5O8mGAyfa2Pb7SfYkuSfJG1r5RuCXgFe1Wd+/auWvS/K3LdauJP/ucBvVxvQLk9wFfDnJ8hnKvrON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/E93ElvfiR5Cb21PQe2Xd2yyE2asyT/HTgNOA74R+BXgQ8C1wMnAZ8Bfryq+m8eGTlJfgj4/4C/5ok1Vr9Eb/3bWPUnyffQu8lgGb3/zF5fVZcm+TZ6//t/Nr2tfF9dVY8uXkvnrn2s9x+q6mXj2I/W5j9sL5cDH6iqLUlWMma/X5PKsXjxOQ6PPsfiObyHCbIkSZL0BJdYSJIkSR0myJIkSVKHCbIkSZLUYYIsSZIkdZggS5IkSR0myFKT5EuHWP+0JB8aVnskaSlyLNYoMEGWJEmSOkyQpT5tNuKjSW5I8qkkv9t2hiLJxlb258C/6VzzDUmuSXJ7kjuTbGrlP5/kmnb83Un+JsnXL0rHJGmMOBZrMZkgS4M9F3gjsB74NuAFSZ4B/Bbwo8C/Br65U/+X6W3beSrwI8BvtO0v3wGcnOT/An4b+HdV9ZWF64YkjTXHYi0KE2RpsNurandVfRX4JLAG+A7gnqr6u+ptQfk7nfovBi5K8kngo8AzgJPa9a8FrgX+V1V9bOG6IEljz7FYi2L5YjdAGlHdfegfZ/a/KwF+rKp2Dji3DvgScPw8tU2SlgrHYi0KZ5ClufsUsCbJt7fX53TO3QT8bGd93HPbn8cA7wT+T2BlkrMXsL2SNIkcizV0JsjSHFXVI8B5wIfbjSGf6Zz+NeDpwF1J7m6vAS4HrqiqTwPnAm9L8o0L2GxJmiiOxVoI6S3fkSRJkgTOIEuSJElPYoIsSZIkdZggS5IkSR0myJIkSVKHCbIkSZLUYYIsSZIkdZggS5IkSR3/P438fbN9c5JQAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xad900910>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(10, 5))\n",
    "plt.subplot(1,2,1)\n",
    "plt.bar(ind,r_error)\n",
    "plt.title(\"Radius Error\")\n",
    "plt.xlabel(\"Index\")\n",
    "plt.ylabel(\"Error\")\n",
    "#plt.xticks(ind)\n",
    "plt.tight_layout()\n",
    "\n",
    "plt.subplot(1,2,2)\n",
    "plt.bar(ind,theta_error)\n",
    "plt.title(\"Theta Error\")\n",
    "plt.xlabel(\"Index\")\n",
    "plt.ylabel(\"Error\")\n",
    "#plt.xticks(ind)\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
